package com.umgsai.thread.thread01;

/**
 * 线程执行的不确定性
 * @author Admin
 *
 */
public class MyThread1 extends Thread {

	@Override
	public void run() {
		try {
			for (int i = 0; i < 10; i++) {
				int time = 	(int) (Math.random() * 1000);
				Thread.sleep(time);
				System.out.println("run=" + Thread.currentThread().getName());
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		try {
			MyThread1 thread = new MyThread1();
			thread.setName("MyThread");
			thread.start();
			for (int i = 0; i < 10; i++) {
				int time = 	(int) (Math.random() * 1000);
				Thread.sleep(time);
				System.out.println("main=" + Thread.currentThread().getName());
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
